#include "HelloWorldScene.h"

USING_NS_CC;

CCScene* HelloWorld::scene()
{
    CCScene *scene = CCScene::create();
    HelloWorld *layer = HelloWorld::create();
    scene->addChild(layer);
    return scene;
}

bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	CCSize s = CCDirector::sharedDirector()->getWinSize();
    
	CCSprite* bg = CCSprite::create("startbg.png");
	bg->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
	addChild(bg);

    return true;
}

void HelloWorld::onEnter(){
	CCLayer::onEnter();
	
	CCSize s = CCDirector::sharedDirector()->getVisibleSize();
	uiLayer = TouchGroup::create();
	addChild(uiLayer);

	Widget* ui = GUIReader::shareReader()->widgetFromJsonFile("UIediter/startUI.ExportJson");
	ui->setSize(s);
	uiLayer->addWidget(ui);

	ActionManager::shareManager()->playActionByName("startUI.ExportJson","startAnim");
}

void HelloWorld::onExit(){
	CCLayer::onExit();

	uiLayer->removeFromParent();
	SceneReader::sharedSceneReader()->purge();
	GUIReader::shareReader()->purge();
	ActionManager::shareManager()->purge();
}